<template>
  <div>
    <BasicTable @register="registerTable">
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'result'">
          {{ formatDictValue(result, record.result) }}
        </template>
      </template>
    </BasicTable>
  </div>
</template>

<script lang="ts" setup>
import { onBeforeMount, ref } from 'vue';
import { BasicTable, useTable } from '/@/components/Table';
import { getLoginLogPageApi } from '/@/api/monitor/login-log';
import { getDictDetailListApi } from '/@/api/sys/dict';
import { columns, searchFormSchema } from './index-option';
import { formatDictValue } from '/@/utils';

const result = ref([]);
onBeforeMount(async () => {
  const { data } = await getDictDetailListApi({ code: 'result' });
  result.value = data;
});

const [registerTable] = useTable({
  title: '登录日志',
  api: getLoginLogPageApi,
  rowKey: 'logId',
  columns,
  formConfig: {
    labelWidth: 80,
    schemas: searchFormSchema,
  },
  striped: false,
  useSearchForm: true,
  bordered: true,
  canResize: true,
  ellipsis: true,
});
</script>
